import {get, post} from './http'
import Axios from 'axios'
//判断管理员是否登录成功
export const getLoginStatus = (params) => post(`admin/login/stutas`, params)

// ============歌手相关================
//添加或修改歌手
export const saveOrUpdateSinger = (params) => post('singer/saveOrUpdate', params)
//获得歌手列表根据参数分页和查询条件
export const getSingerList = (params) => get('singer/list', params)
//获取指定id的歌手信息
export const getSingerInfo = (id) => get(`singer/info/${id}`)
//删除[批量] 指定歌手信息
export const deleteSinger = (ids) => post(`singer/delete`, ids)
//查询歌手数量
export const getAllSinger = () => get(`singer/allSinger`)


// ============歌手歌曲相关================
//获取歌曲[分页]列表 可以添加查询条件[歌手id 歌曲名]
export const getSongList = (params) => get(`song/list`, params)

//添加或修改歌曲信息
export const updateSongInfo = (params) => post(`song/update`, params)
//获取指定id的歌曲信息
export const getSongInfo = (id) => get(`song/info/${id}`)
//删除指定歌曲信息
export const deleteSong = (ids) => post('song/delete', ids)
//查询歌曲数量
export const allSong = () => get(`song/allSong`)

// ============歌单相关================
//歌单信息的添加修改
export const saveOrUpdateSongList = (params) => post('songList/saveOrUpdate', params)
//获取[分页]歌单列表[可以根据指定条件]
export const getSongLists = (params) => get('songList/list', params)
//获取指定id的歌单信息
export const getSongListInfo = (id) => get(`songList/info/${id}`)
//删除[批量]指定id歌单信息
export const deleteSongList = (ids) => post(`songList/delete`, ids)

// ============歌单歌曲相关================
//根据歌单id查询歌曲列表
export const listSongDetail = (songListId) => get('listSong/detail', songListId)
//给歌单增加歌曲
export const addSongToListSong = (params) => post('listSong/add', params)
//删除歌单的歌曲
export const deleteListSongByIds = (ids) => post('listSong/deleteByIds', ids)

// ============前端用户相关================
export const saveOrUpdateConsumer = (params) => post('consumer/saveOrUpdate', params)

export const getConsumerList = (params) => get('consumer/list', params)

export const getConsumerInfo = (id) => get(`consumer/info/${id}`)

export const deleteConsumer = (ids) => post(`consumer/delete`, ids)
// 注册
export const SignUp = (params) => post(`/consumer/saveOrUpdate`, params)
//登录
export const loginIn =(params) => post(`/consumer/login`,params);

//下载音乐
export const download = (url) => Axios({
    method: 'get',
    url: url,
    responseType: 'blob'
})

//===========评价======================
//提交评分
export const setRank = (params) => post(`/rank/add`, params)
//获取指定歌单的平均分
export const getRankOfSongListId = (songListId) => get(`/rank?songListId=${songListId}`)

//===========评论======================
//提交评论
export const setComment = (params) => post(`/comment/saveOrUpdate`, params)
//点赞
export const setLike = (params) => post(`/comment/like`, params)
//返回当前歌单或歌曲的评论列表
export const getAllComment = (type, id) => {
    if (type === 0) {              //歌曲
        return get(`/comment/commentOfSongId?songId=${id}`)
    } else {                      //歌单
        return get(`/comment/commentOfSongListId?songListId=${id}`)
    }
}

//===============收藏===================
//新增收藏
export const setCollect = (params) => post(`/collect/add`, params)
//指定用户的收藏列表
export const getCollectOfUserId = (userId) => get(`/collect/collectOfUserId?userId=${userId}`)